package com.fuershiye.woman.monitor.controller;

import java.util.List;

import com.fuershiye.woman.monitor.service.*;
//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.fuershiye.woman.monitor.beans.IdName;
import com.fuershiye.woman.monitor.beans.IdNamePid;
import com.fuershiye.woman.monitor.beans.IdNameSname;
import com.fuershiye.woman.monitor.model.Unit;
import com.fuershiye.woman.monitor.utils.DateFormatUtil;

/**
 * 报表页面显示管理
 * 
 * @author yongyongdong
 *
 */
@Controller
@RequestMapping(value = "/report/view")
public class ReportViewController {

	private static final Logger logger = LoggerFactory
			.getLogger(ReportViewController.class);

	@Autowired
	DepartmentService departmentService;
	@Autowired
	IndicatorTypeService indicatorTypeService;
	@Autowired
	IndicatorService indicatorService;
	@Autowired
	UnitService unitService;
	@Autowired
	FormsService formsService;
	
//	@RequiresPermissions("report:mapView")
	@RequestMapping(value = "/mapView.do")
	public String mapView(String show, Model model) {

		List<Integer> years = DateFormatUtil.getAreaYears();
		model.addAttribute("years", years);

		List<IdName> formes = formsService.getAllNames();
		model.addAttribute("formes", formes);

		return "map/" + show;
	}
	
//	@RequiresPermissions("report:mapView")
	@RequestMapping(value = "/collectView.do")
	public String collectView(String show, Model model) {

		List<IdName> formes = formsService.getAllNames();
		// 表 forms 的ID ： 1:妇儿 2:社会
		model.addAttribute("formes", formes);

		List<Integer> years = DateFormatUtil.getAreaYears();
		model.addAttribute("years", years);

		return "collect/" + show;
	}
	
//	@RequiresPermissions("report:mapView")
	@RequestMapping(value = "/aggregateView.do")
	public String aggregateView(Model model, String show) {

		List<Integer> years = DateFormatUtil.getAreaYears();
		model.addAttribute("years", years);

		List<IdName> formes = formsService.getAllNames();
		// 表 forms 的ID ： 1:妇儿 2:社会
		model.addAttribute("formes", formes);

		return "aggregate/" + show;
	}
	
//	@RequiresPermissions("report:mapView")
	@RequestMapping(value = "/selfView.do")
	public String selfView(String show, Model model) {

		List<IdName> formes = formsService.getAllNames();
		// 表 forms 的ID ： 1:妇儿 2:社会
		model.addAttribute("formes", formes);

		List<Integer> years = DateFormatUtil.getAreaYears();
		model.addAttribute("years", years);

		return "report/" + show;

	}
	
//	@RequiresPermissions("report:mapView")
	@RequestMapping(value = "/departView.do")
	public String departView(Model model, String show) {

		List<Integer> years = DateFormatUtil.getAreaYears();
		model.addAttribute("years", years);

		List<IdName> indicatorType = indicatorTypeService.getByCondition(null, "", 1);
		model.addAttribute("indicatorTypes", indicatorType);

		List<IdNamePid> indicatores = indicatorService.getAllNames();
		model.addAttribute("indicatores", indicatores);

		List<IdName> formes = formsService.getAllNames();
		model.addAttribute("formes", formes);

		return "report/" + show;
	}

	// 我要上报
//	@RequiresPermissions("report:addView")
	@RequestMapping(value = "/addView.do")
	public String addView(String show, Model model) {

		List<IdNameSname> departmentes = departmentService.getAllSnames(null,null,null);
		model.addAttribute("departmentes", departmentes);

		// 表 forms 的ID ： 1:妇儿 2:社会
		List<IdName> formes = formsService.getAllNames();
		model.addAttribute("formes", formes);

		List<Integer> years = DateFormatUtil.getHalfYears();
		model.addAttribute("years", years);

		List<Unit> unites = unitService.list("", 1);
		model.addAttribute("unites", unites);

		return "report/" + show;
	}

}
